package com.cn.stusy0015.demo0010;

import java.util.Scanner;

/**
 * @author lw
 * @ClassName ValidaterID.java
 * @Description
 * @createTime 2023年05月20日 11:53:00
 */
public class ValidaterID {
    public static void main(String[] args) {
        System.out.println("***欢迎进入注册系统****");
        Scanner sc = new Scanner(System.in);
        String[] telstr = new String[5];
        do {
            System.out.print("请输入身份证:");
            String idCard = sc.next();
            System.out.print("请输入手机号:");
            String mobile = sc.next();
            System.out.print("请输入座机号:");
            String tel = sc.next();
            if (tel.indexOf("-") != -1) {
                telstr = tel.split("-");
            } else {
                System.out.println("请输入正确的座机号码！");
                continue;
            }
            if (idCard.length() == 18 || idCard.length() == 16) {
                if (mobile.length() != 11) {
                    System.out.println("手机号必须是11位，请重新输入：");
                }else {
                    if (telstr[0].length() != 4 ||  telstr[1].length() != 7) {
                        System.out.println("主机号码必须为4位，电话号码必须为7位");
                    }else {
                        System.out.println("注册成功！");
                        break;
                    }
                }
            }else {
                System.out.println("身份证必须是18位或16位，请重新输入：");
            }
        } while (true);

    }
}
